package com.ailot.cloud.upms.api.service.impl;

import com.ailot.cloud.base.common.constants.CommonConstant;
import com.ailot.cloud.upms.api.mapper.SysRoleMapper;
import com.ailot.cloud.upms.api.service.SysRoleService;
import com.ailot.cloud.upms.common.entity.SysRole;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 角色管理
 */
@Service
public class SysRoleServiceImpl extends ServiceImpl<SysRoleMapper, SysRole> implements SysRoleService {

    @Override
    public List<String> getRoleIdsByUserId(String userId) {
        return baseMapper.getRoleIdsByUserId(userId);
    }

    /**
     * 校验是否是管理员角色
     *
     * @param roleId 主键id
     */
    @Override
    public boolean judeAdmin(String roleId) {
        SysRole sysRole = this.getById(roleId);
        if (CommonConstant.ROLE_CODE_ADMIN.equals(sysRole.getRoleCode())) {
            return Boolean.TRUE;
        }
        return Boolean.FALSE;
    }
}
